﻿using Idte.Common.ArtifactModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Idte.Common.Process
{
    public class ExecutionContext : IExecutionContext
    {
        public IControlFlow Flow { get; set; }

        private Artifact _contextData;
        public Artifact Data
        {
            get
            {
                if (_contextData == null)
                {
                    _contextData = new Artifact();
                }
                return _contextData;
            }
            set { _contextData = value; }
        }

        public IExecutionContext Execute()
        {
            IExecutionContext current = this;
            while (Flow.MoveNext(current))
            {
                current = Flow.Current.Create().Execute(current);
            }
            return current;
        }
    }
}
